package net;

/**
 * @projectName: java-sample
 * @description:
 * @author: Adam
 * @create: 2020-01-05 20:05
 **/

public class MutiThreadDown {

    public static void main(String[] args) throws Exception{
        final DownUtil downUtil = new DownUtil("http://localhost:8888/static/plugins/jquery/jquery.min.js","oracelsql.rar",4);
        //开始下载
        downUtil.download();

        new Thread(){
            public void run(){
                while (downUtil.getCompleteRate()<1){
                    //每隔0.1秒查询一次任务的完成进度
                    //GUI程序中可根据该进度来绘制进度条
                    System.out.println("已完成:"+downUtil.getCompleteRate());
                    try {
                        Thread.sleep(1000);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }
        }.start();
    }
}
